<template>
  <view class="mymap">

    <web-view :src="myurl"></web-view>

    <!-- 引入需要嵌入的h5 链接 -->
    <!-- <web-view @message="message" src="http://192.168.2.23:8080"></web-view> -->

    <!-- //在methods中接收h5发送的消息/*** @information message中 接收到的是由h5项目通过uni.postMessage中传递出来的数据，以数组的形式接收每次的消息*/message(event){console.log('接收到消息'，event.detail.data)} -->
  </view>
</template>

<script>
var wv; //计划创建的webview
export default {
  data() {
    return {
      myurl: '',
      message: '123456789',
      canBack: false,
      gftj: false
    }
  },
  onUnload() {
    if (this.gftj) {
      let pages = getCurrentPages();
      let last = pages[pages.length - 2];
      return uni.navigateTo({
        url: last.$page
      })
    }
    uni.reLaunch({
      url: '/pages/index/index'
    })
  },
  onBackPress() {

  },
  onReady() {

  },
  onLoad(options) {
    if (options.islandIdStr) this.gftj = true;
    uni.getLocation({
      type: 'gcj02', //设置type为gcj02
      isHighAccuracy: true,
      success: async (res) => {
        console.log(res);
        const {
          latitude,
          longitude
        } = res;
        //	console.log(latitude,longitude,'5464564564645');
        let authorization = uni.getStorageSync('access_token') || '';

        let myuserId;
        if (uni.getStorageSync('userInfo')) {
          myuserId = JSON.parse(uni.getStorageSync('userInfo')).id;

        } else {
          myuserId = 110;
        }

        this.myurl = 'https://i.ringzle.com/h5/#/?authorization=' + authorization + "&lon=" + longitude + "&lat=" + latitude + "&myuserId=" + myuserId + "&islandIdStr=" + (options.islandIdStr || '');
        // this.myurl = 'http://192.168.2.23:8080/h5/#/?authorization=' + authorization + "&lon=" + longitude + "&lat=" +latitude + "&myuserId=" +myuserId+"&islandIdStr="+(options.islandIdStr||'');
      },
    });


    //let userInfo = JSON.parse(decodeURIComponent(options.info));
    //console.log('userInfo', userInfo);
    // let authorization = uni.getStorageSync('access_token') || '';
    // console.log('111111111111111111', authorization)
    // let myuserId = JSON.parse(uni.getStorageSync('userInfo')).id || '';

    //this.myurl = 'https://i.ringzle.com/h5/#/?authorization=' + authorization + "&lon=" + userInfo.lon + "&lat=" +
    //	userInfo.lat ;
    //console.log('111111111111111111', this.myurl)

  },
  methods: {

  }
}
</script>

<style>
/* #ifdef H5 */
/* 页面A */
uni-page[data-page="pages/touristMap/index"] .uni-page-head-hd {
  display: none;
}

/* #endif */
/* #ifdef H5 */
uni-page-head {
  display: none;
}

/* #endif */

.mymap {
  width: 100%;
  height: calc(100vh - 45px);
}
</style>